import 'package:flutter/material.dart';

class CustomScrollViewCase extends StatelessWidget {
  const CustomScrollViewCase({super.key});

  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: [
        SliverToBoxAdapter(
          child: Container(
            height: 200,
            color: Colors.grey,
            alignment: Alignment.center,
            child: const Text('轮播图'),
          ),
        ),
        const SliverToBoxAdapter(
          child: SizedBox(height: 5),
        ),
        SliverGrid.builder(
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,
            mainAxisSpacing: 5,
            crossAxisSpacing: 5,
            // childAspectRatio: 2 / 1,
            mainAxisExtent: 100,
          ),
          itemBuilder: (context, index) {
            return Container(
              height: 100,
              color: Colors.pink,
              alignment: Alignment.center,
              child: const Text('传智教育'),
            );
          },
          itemCount: 6,
        ),
        // 普通盒子需要被嵌套在 SliverToBoxAdapter 中
        const SliverToBoxAdapter(
          child: SizedBox(height: 5),
        ),
        SliverList.separated(
          separatorBuilder: (context, index) {
            return const SizedBox(height: 5);
          },
          itemBuilder: (context, index) {
            return Container(
              height: 100,
              color: Colors.orange,
              alignment: Alignment.center,
              child: const Text('传智教育'),
            );
          },
          itemCount: 10,
        ),
      ],
    );
  }
}
